package com.simple.proxy.dynamic.cglib;

import net.sf.cglib.proxy.Enhancer;

public class CglibProxyUtil {

    public static <T> T getCglibProxy(Object o){
        Enhancer enhancer = new Enhancer();
        // 设置代理类的父类
        enhancer.setSuperclass(o.getClass());
        // 设置回调对象
        enhancer.setCallback(new CglibProxy());
        // 创建代理对象
        return (T) enhancer.create();
    }
}
